package com.aspose.cells.b.a.b;

import com.aspose.cells.Color;
import com.aspose.cells.a.d.zbw;
import com.aspose.cells.a.d.zfq;
import com.aspose.cells.a.d.zfs;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.RenderingHints.Key;
import java.awt.geom.AffineTransform;
import java.awt.image.ImageObserver;
import java.util.Map;

public class zi {
   protected final Graphics2D a;
   float b = 1.0F;
   int c = 1;
   private com.aspose.cells.b.a.b.a.zi d;
   private static final float[] e = new float[]{1.0F, 1.0F, 1.0F, (float)c() / 72.0F, (float)c(), (float)c() / 300.0F, (float)c() / 25.4F};

   public static final float[] a() {
      return e;
   }

   protected zi(Graphics2D var1) {
      this.a = var1;
      this.d = new com.aspose.cells.b.a.b.a.zi();
   }

   public Graphics2D b() {
      return this.a;
   }

   public static int c() {
      return 96;
   }

   public void a(Color var1) {
      throw new com.aspose.cells.a.c.zb("");
   }

   public void d() {
      this.e();
   }

   public void e() {
      this.a.finalize();
   }

   public void a(zj var1, float var2, float var3, float var4, float var5) {
      this.a.drawImage(var1.f(), (int)var2, (int)var3, (int)var4, (int)var5, (ImageObserver)null);
   }

   public void a(zj var1, zn var2) {
      this.a.drawImage(var1.f(), var2.a(), var2.b(), (ImageObserver)null);
   }

   public void a(zj var1, int var2, int var3) {
      this.a.drawImage(var1.f(), var2, var3, (ImageObserver)null);
   }

   public void a(zj var1, zq var2, zq var3, int var4) {
      this.a.drawImage(var1.f(), (int)var2.f(), (int)var2.g(), (int)var2.l(), (int)var2.m(), (int)var3.f(), (int)var3.g(), (int)var3.l(), (int)var3.m(), (ImageObserver)null);
   }

   public void a(zj var1, zp var2, zp var3, int var4) {
      this.a.drawImage(var1.f(), var2.c(), var2.d(), var2.i(), var2.j(), var3.c(), var3.d(), var3.i(), var3.j(), (ImageObserver)null);
   }

   public void a(String var1, zg var2, zc var3, zq var4, zv var5) {
      this.a(var1, var2, var3, var4.f(), var4.g(), var4.h(), var4.i(), var5);
   }

   public void a(String var1, zg var2, zc var3, float var4, float var5, zv var6) {
      this.a(var1, var2, var3, var4, var5, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, var6);
   }

   private void a(String var1, zg var2, zc var3, float var4, float var5, float var6, float var7, zv var8) {
      if (var3 == null) {
         throw new IllegalArgumentException("brush");
      } else if (var2 == null) {
         throw new IllegalArgumentException("font");
      } else {
         if (var8 != null && var8.b() != 0) {
            zt var9 = this.a(var1, var2, (zv)var8, var6, var7, (int[])null);
            float var10 = var6;
            float var11 = var7;
            if (com.aspose.cells.b.a.zu.b(var6)) {
               var11 = 0.0F;
               var10 = 0.0F;
            }

            float var12 = var8.f() ? var10 - var9.b() : var11 - var9.c();
            float var13 = var8.b() == 1 ? var12 / 2.0F : var12;
            if (var8.f()) {
               if (!var8.g() || var8.b() != 2) {
                  var4 += var13;
               }

               if (!com.aspose.cells.b.a.zu.b(var6)) {
                  var6 -= var12;
               }
            } else {
               var5 += var13;
               if (!com.aspose.cells.b.a.zu.b(var6)) {
                  var7 -= var12;
               }
            }
         }

         Paint var30 = this.a.getPaint();
         this.a.setPaint(var3.g());

         try {
            AffineTransform var31 = this.a.getTransform();

            try {
               boolean var32 = com.aspose.cells.b.a.zu.b(var6) || var8 != null && var8.j();
               Shape var33 = null;
               if (!var32) {
                  var33 = this.a.getClip();
                  this.a.clip(new java.awt.geom.Rectangle2D.Float(var4, var5, var6, var7));
               }

               try {
                  com.aspose.cells.b.a.b.d.a.zd var34 = new com.aspose.cells.b.a.b.d.a.zd(var1, var2, var8, var6, var7, this.a);
                  this.a.transform(var34.l());

                  for(com.aspose.cells.b.a.b.d.a.zc var14 = var34.m(); var14 != null; var14 = var34.m()) {
                     var14.a(this.a, var4 * e[this.c], var5 * e[this.c]);
                  }
               } finally {
                  if (!var32) {
                     this.a.setClip(var33);
                  }

               }
            } finally {
               this.a.setTransform(var31);
            }
         } finally {
            this.a.setPaint(var30);
         }

      }
   }

   public static zi a(zj var0) {
      zb var1 = new zb((Graphics2D)var0.f().getGraphics(), var0.i(), var0.h());
      return var1;
   }

   public float f() {
      return 96.0F;
   }

   public zt a(String var1, zg var2) {
      return this.a(var1, var2, (zv)null, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, (int[])null);
   }

   public zt a(String var1, zg var2, zt var3) {
      return this.a(var1, var2, (zt)var3, (zv)null);
   }

   public zt a(String var1, zg var2, zo var3, zv var4) {
      return this.a(var1, var2, (zv)var4, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, (int[])null);
   }

   public zt a(String var1, zg var2, zt var3, zv var4) {
      return this.a(var1, var2, (zv)var4, var3.b(), var3.c(), (int[])null);
   }

   public zt a(String var1, zg var2, int var3, zv var4) {
      return this.a(var1, var2, (zv)var4, (float)var3, Float.POSITIVE_INFINITY, (int[])null);
   }

   private final zt a(String var1, zg var2, zv var3, float var4, float var5, int[] var6) {
      try {
         if (var6 != null) {
            var6[0] = 0;
            var6[1] = 0;
         }

         zg var7 = var2;
         String var8 = var2.b().b();
         if (!zfs.a(var8, var2.k(), var1)) {
            var8 = zbw.a;
            if (!zfs.a(var8, var2.k(), var1)) {
               zfq var9 = zfs.a(var2.k(), var1);
               if (var9 != null) {
                  var8 = var9.b();
                  var7 = new zg(var8, var2.h(), var2.k());
               } else {
                  var8 = zbw.a;
                  var7 = new zg(var8, var2.h(), var2.k());
               }
            }
         }

         com.aspose.cells.b.a.b.d.a.zd var15 = new com.aspose.cells.b.a.b.d.a.zd(var1, var7, var3, var4, var5, this.a);
         float var10 = 0.0F;
         int var11 = 0;

         float var13;
         for(com.aspose.cells.b.a.b.d.a.zc var12 = var15.m(); var12 != null; var12 = var15.m()) {
            ++var11;
            var13 = var12.b();
            if (var13 > var10) {
               var10 = var13;
            }
         }

         if (var11 == 0) {
            return zt.a();
         } else {
            float var16 = var15.j();
            if (var3 != null && var3.f()) {
               var13 = var16;
               var16 = var10;
               var10 = var13;
            }

            if (var3 == null || !var3.j()) {
               if (var10 > var4) {
                  var10 = var4;
               }

               if (var16 > var5) {
                  var16 = var5;
               }
            }

            if (var6 != null) {
               var6[0] = var11;
               var6[1] = var15.i();
            }

            return new zt(var10, var16);
         }
      } catch (Throwable var14) {
         return new zt(var4, var5);
      }
   }

   public com.aspose.cells.b.a.b.a.zf g() {
      return null;
   }

   public void a(float var1, float var2) {
      this.a.scale((double)var1, (double)var2);
   }

   public void a(int var1) {
      this.c = var1;
   }

   public void b(int var1) {
   }

   public void c(int var1) {
   }

   public void a(com.aspose.cells.b.a.b.a.zi var1) {
      var1.a(this.d);
      this.a.setTransform(this.d.a());
   }

   public void a(Map<Key, Object> var1) {
      this.a.setRenderingHints(var1);
   }
}
